//
// Created by 吴喆 on 2020/3/5.
//

#ifndef SUMMER_PLAYABLE_H
#define SUMMER_PLAYABLE_H


#import <vector>
#import <map>

#import "GameObject.h"
#import "Input.h"
#import "Animation.h"
#include "Body.h"
#include "Floor.h"
#import "Scene.h"
#include "StateMachine.h"

class PlayableState;

class Scene;



// 角色基本动作状态
//enum ACTION {
//    BIRTH, STAND, STAND_ATTACK, RUN, RUN_ATTACK, JUMP, JUMP_ATTACK, FALL, FALL_ATTACK, DEAD
//};

/**
 * {@code Playable} is movable, and has the direction
 * {@code Playable} has {@code body} field to control moving
 */
class Playable : public GameObject {
public:
    explicit Playable(const Scene *scene_, DIRECTION direction = DIRECTION::RIGHT);

    ~Playable() override;

    virtual void initBox();

    void update() override;


    /**
     * store the state machines.
     */
    std::vector<StateMachine *> machines = std::vector<StateMachine *>();

    /**
     * the animation which is currently playing
     */
    Animation *currentAnimation = nullptr;

    /**
     * to control position and move
     */
    Body body;

    /**
     * is attacking?
     */
    bool isAtk = false;

    /**
     * is in the slope?
     */
    bool inSlope = false;

    /**
     * move speed
     */
    float speed = 4.0;

    /**
     * floor which {@code Playable} stand
     */
    Floor *floor = nullptr;

protected:
    /**
     * init sensor field
     */
    virtual void initSensorField();

    virtual void handleInput(KeyEvent *pEvent);

public:

};


#endif //SUMMER_PLAYABLE_H
